﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Vikipedia.CommonTools.Subtitles;
namespace Vikipedia.VikiPlayer.WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

        }

        private void Window_DragOver(object sender, DragEventArgs e)
        {
            
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effects = DragDropEffects.Copy;
                e.Handled = true;


            }
            else
            {
                e.Effects = DragDropEffects.None  ;
                e.Handled = true ;
            }
  
        }



        private void Window_Drop(object sender, DragEventArgs e)
        {
            string [] files = e.Data.GetData(DataFormats.FileDrop) as string [];
            var u=new Uri (files[0]);
            this.PlayerElement.Source=u;
            var subs = u.LocateLocalSubtitles();
            this.Resources["Projectionist"] = new RollingSubtitleProjectionist()
            {
               
                Position = TimeSpan.Zero,
                SubtitleSource = subs.Values.First () as IList <ISubtitleItem >
            };
        }

        //private void ProgressBar_MouseDown(object sender, MouseButtonEventArgs e)
        //{
        //    ProgressBar.Value = ProgressBar.Maximum / ProgressBar.ActualWidth * e.GetPosition(ProgressBar).X;
   
        //}
    }
}
